package org.creativor.rayson.transport.server.transfer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.lang.reflect.Method;
import org.creativor.rayson.api.TransferArgument;
import org.creativor.rayson.api.TransferService;
import org.creativor.rayson.api.TransferSocket;
import org.creativor.rayson.demo.proxy.DemoTransferArgument;
import org.creativor.rayson.demo.server.DemoTransferService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>TransferInvokerTest</code> contains tests for the class <code>{@link TransferInvoker}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 *
 * @generatedBy CodePro at 11-5-7 上午3:15
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class TransferInvokerTest {
	/**
	 * Run the TransferInvoker(short,TransferService,Method) constructor test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testTransferInvoker_1()
		throws Exception {
		short code = (short) 1;
		TransferService service = new DemoTransferService();
		Method method = Object.class.getMethods()[0];

		TransferInvoker result = new TransferInvoker(code, service, method);

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals((short) 1, result.getCode());
	}

	/**
	 * Run the short getCode() method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testGetCode_1()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);

		short result = fixture.getCode();

		// TODO: add additional test code here
		assertEquals((short) 1, result);
	}

	/**
	 * Run the TransferService getService() method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testGetService_1()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);

		TransferService result = fixture.getService();

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the void invoke(TransferArgument,TransferSocket) method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.lang.IllegalArgumentException.class)
	public void testInvoke_1()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);
		TransferArgument argument = new DemoTransferArgument("");
		TransferSocket transferSocket = null;

		fixture.invoke(argument, transferSocket);

		// TODO: add additional test code here
	}

	/**
	 * Run the void invoke(TransferArgument,TransferSocket) method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.lang.IllegalArgumentException.class)
	public void testInvoke_2()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);
		TransferArgument argument = new DemoTransferArgument("");
		TransferSocket transferSocket = null;

		fixture.invoke(argument, transferSocket);

		// TODO: add additional test code here
	}

	/**
	 * Run the void invoke(TransferArgument,TransferSocket) method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.lang.IllegalArgumentException.class)
	public void testInvoke_3()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);
		TransferArgument argument = new DemoTransferArgument("");
		TransferSocket transferSocket = null;

		fixture.invoke(argument, transferSocket);

		// TODO: add additional test code here
	}

	/**
	 * Run the void invoke(TransferArgument,TransferSocket) method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.lang.IllegalArgumentException.class)
	public void testInvoke_4()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);
		TransferArgument argument = new DemoTransferArgument("");
		TransferSocket transferSocket = null;

		fixture.invoke(argument, transferSocket);

		// TODO: add additional test code here
	}

	/**
	 * Run the boolean isSupportedVersion(short) method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testIsSupportedVersion_1()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);
		short clientVersion = (short) 1;

		boolean result = fixture.isSupportedVersion(clientVersion);

		// TODO: add additional test code here
		assertEquals(true, result);
	}

	/**
	 * Run the boolean isSupportedVersion(short) method test.
	 *
	 * @throws Exception
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testIsSupportedVersion_2()
		throws Exception {
		TransferInvoker fixture = new TransferInvoker((short) 1, new DemoTransferService(), Object.class.getMethods()[0]);
		short clientVersion = (short) 1;

		boolean result = fixture.isSupportedVersion(clientVersion);

		// TODO: add additional test code here
		assertEquals(true, result);
	}

	/**
	 * Perform pre-test initialization.
	 *
	 * @throws Exception
	 *         if the initialization fails for some reason
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Before
	public void setUp()
		throws Exception {
		// TODO: add additional set up code here
	}

	/**
	 * Perform post-test clean-up.
	 *
	 * @throws Exception
	 *         if the clean-up fails for some reason
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@After
	public void tearDown()
		throws Exception {
		// TODO: add additional tear down code here
	}

	/**
	 * Launch the test.
	 *
	 * @param args the command line arguments
	 *
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	public static void main(String[] args) {
		new org.junit.runner.JUnitCore().run(TransferInvokerTest.class);
	}
}